package com.zd.service.impl;

import com.zd.dao.CommentsDao;
import com.zd.entity.Comments;
import com.zd.service.CommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CommentsServiceImpl implements CommentsService {
    @Autowired
    private CommentsDao commentsDao;

    @Override
    public List<Comments> queryAllCommentsByNid(Long nid) {
        return commentsDao.getAllByCnidOrderByCdateDesc(nid);
    }

    @Override
    public Comments publishCommments(Comments comments) {
        comments.setCdate(new Date());
        return commentsDao.save(comments);
    }
}
